# -*- coding: utf-8 -*-
"""
Created on Fri Jul  3 02:44:49 2020

@author: Farman
"""


import ClassificationSamples.SampleMan as sampleman
import Landsat.LandsatFileListMan as landsatfilesman
import GeotiffMan
import joblib
import utm
import sys


sample_man = sampleman.ClassificationSamples('/public/home/yule/code/team-w/ClassificationSamples/SamplesFromMrYu.joblib')
landsat_man = landsatfilesman.LandsatFilesMan('/public/home/yule/code/team-w/WorkDir/landsat_files.joblib')
dict_path_row_id = joblib.load('/public/home/yule/code/team-w/WorkDir/samples_path_row_id.joblib')

def generate_script():
    commands = []

    path = dict_path_row_id.keys()
    path = list(path)
    path.sort()

    for p in path:
        dict_row_id = dict_path_row_id.get(p)

        row = dict_row_id.keys()
        row = list(row)
        row.sort()

        for r in row:
            command = "python ../LandsatSampleFetch.py %d %d"%(p, r)
            commands.append(command)

    # for debug
    #commands = commands[:5]
    print('Total commands :', len(commands))

    command_text = '\n'.join(commands)
    #print(command_text)

    with open('/public/home/yule/code/team-w/WorkDir/sample_fetch.run', 'w') as f:
        f.write(command_text)


if __name__ == '__main__':
    generate_script()